package com.htrq.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.htrq.entity.ICKzcxx;
import com.htrq.entity.Page;
import com.htrq.service.ICardzcService;
import com.htrq.util.ExportToExcelUtil;

@Controller
@RequestMapping("jsp/basinfo")
public class ICardzcController {
	
	@Resource
	private ICardzcService zcService;
	
	@RequestMapping("getAllizc")
	public String getAllizc(ICKzcxx zc, Page page, HttpServletResponse response) throws IOException, ParseException {
		List<ICKzcxx> list=zcService.getAllizc(zc,page);
		String str=JSON.toJSONString(list);
		Long total=zcService.getTotal(zc);
		String json="{total:"+total+",kzcs:"+str+"}";
		response.setContentType("text/html;charset=utf8");
		PrintWriter out =response.getWriter();
		out.write(json);
		return null;
	}
	
	@RequestMapping("exportzc")
	public String exportzc(ICKzcxx zc,HttpServletRequest request,HttpServletResponse response)throws Exception{
		String titles[]={"转出卡号","转入卡号","转存金额","转存时间","转存站点","班次","转存原因","操作员"};
		List<Object[]> list=zcService.exportbyForm(zc);
		ExportToExcelUtil.exportToExcel(request,response,"卡转存查询导出结果.xls", "记录", titles, list);
		return null;
	}
}
